//
//  YHWorkGroup.m
//  IhuayuanClient
//
//  Created by 黄思清 on 2017/7/4.
//  Copyright © 2017年 com.ihuayuan. All rights reserved.
//

#import "YHWorkGroup.h"
#import <UIKit/UIKit.h>


extern const CGFloat contentLabelFontSize;
extern CGFloat maxContentLabelHeight;
extern CGFloat maxContentRepostLabelHeight;
extern const CGFloat kMarginContentLeft;
extern const CGFloat kMarginContentRight;

@implementation YHWorkGroup
{
    CGFloat _lastContentWidth;
}

@synthesize msgContent = _msgContent;


- (void)setMsgContent:(NSString *)msgContent
{
    _msgContent = msgContent;
}

- (NSString *)msgContent
{
    CGFloat contentW = MAIN_SCREEN_WIDTH - kMarginContentLeft - kMarginContentRight ;
    if (contentW != _lastContentWidth) {
        _lastContentWidth = contentW;
        CGRect textRect = [_msgContent boundingRectWithSize:CGSizeMake(contentW, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:contentLabelFontSize]} context:nil];

            if (textRect.size.height > maxContentLabelHeight+contentLabelFontSize) {
                _shouldShowMoreButton = YES;
            } else {
                _shouldShowMoreButton = NO;
            }
    }
    return _msgContent;
}

- (void)setIsOpening:(BOOL)isOpening
{
    if (!_shouldShowMoreButton) {
        _isOpening = NO;
    } else {
        _isOpening = isOpening;
    }
}

@end
